import { orderList, orderFlowMes, orderStopMes } from '@/api/system/order'
const state = {
    id: '',
    list: [],
    orderFlowMesList: [],
    orderStopMesList: [],
}
const actions = {
    orderListAPI(context, value) {
        orderList(value).then(res => {
            console.log(res.data);
            context.commit('ORDERListAPI', res.data)
        })
    },
    orderFlowMesListAPI(context, value) {
        orderFlowMes(value).then(res => {
            context.commit('ORDERFLOWMESLISTAPI', res.data)
        })
    },
    orderStopMesAPI(context, value) {
        orderStopMes(value).then(res => {
            context.commit('ORDERSTOPLISTAPI', res.data)
        })
    }
}
const mutations = {
    ORDERListAPI(state, value) {
        state.list = value
        value.map(item => {
            if (item.orderNo !== null) {
                if (item.orderNo.indexOf('*') !== -1) {
                    item.orderNo = item.orderNo.replace(/\*/g, "\n");
                }
                if (item.orderNo.indexOf('.') !== -1) {
                    item.orderNo = item.orderNo.replace(/\./g, "\n");
                }

            }
            if (item.partNo !== null) {
                if (item.partNo.indexOf('*') !== -1) {
                    item.partNo = item.partNo.replace(/\*/g, "\n");
                }
                if (item.partNo.indexOf('.') !== -1) {
                    item.partNo = item.partNo.replace(/\./g, "\n");
                }
            }



        })

    },
    ORDERFLOWMESLISTAPI(state, value) {
        state.orderFlowMesList = value
    },
    ORDERSTOPLISTAPI(state, value) {
        state.orderStopMesList = value
        console.log(value, 'sadadadqqq');

    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}